package com.evil.application.service;

import com.baomidou.mybatisplus.extension.service.IService;
import com.evil.application.pojo.dto.permission.control.ControlPermissionDTO;
import com.evil.application.pojo.dto.permission.control.ModifyControlPermissionReqDTO;
import com.evil.application.pojo.entity.ControlPermission;
import com.evil.common.application.dto.permission.control.ControlPermissionSourceDTO;
import com.evil.common.application.dto.permission.control.ControlPermissionsReqDTO;
import com.evil.common.application.dto.permission.control.CopyControlPermissionReqDTO;

import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.Set;

/**
 * 控件权限配置表
 *
 * @author liyang
 * @date 2022-08-08 00:00
 */
public interface ControlPermissionService extends IService<ControlPermission> {

    /**
     * 保存控件权限
     *
     * @param modifyControlPermissionReqDTO modifyControlPermissionReqDTO
     */
    void saveControlPermissions(ModifyControlPermissionReqDTO modifyControlPermissionReqDTO);

    /**
     * 复制控件权限
     *
     * @param controlPermissionReqDTO controlPermissionReqDTO
     */
    void copyControlPermissions(CopyControlPermissionReqDTO controlPermissionReqDTO);

    /**
     * 删除控件权限
     *
     * @param controlPermissionsReqDTO controlPermissionsReqDTO
     */
    void deleteControlPermissions(ControlPermissionsReqDTO controlPermissionsReqDTO);

    /**
     * 获取控件权限基础信息
     *
     * @param controlPermissionSourceDTO controlPermissionSourceDTO
     * @return List
     */
    List<ControlPermissionDTO> findBasesBySource(ControlPermissionSourceDTO controlPermissionSourceDTO);

    /**
     * 获取节点控件权限
     *
     * @param nodeId     nodeId
     * @param controlIds controlIds
     * @return List
     */
    List<ControlPermissionDTO> nodeControlPermissions(Long nodeId, Collection<Long> controlIds);

    /**
     * 获取节点控件权限
     *
     * @param nodeIds           nodeIds
     * @param nodeControlIdsMap nodeControlIdsMap
     * @return List
     */
    List<ControlPermissionDTO> nodesControlPermissions(Collection<Long> nodeIds, Map<Long, Set<Long>> nodeControlIdsMap);

    /**
     * 获取节点控件权限
     *
     * @param nodeIds           nodeIds
     * @param nodeControlIdsMap nodeControlIdsMap
     * @return Map
     */
    Map<Long, List<ControlPermissionDTO>> nodesControlPermissionMap(Collection<Long> nodeIds, Map<Long, Set<Long>> nodeControlIdsMap);

    /**
     * 获取节点可见控件权限
     *
     * @param nodeIds           nodeIds
     * @param nodeControlIdsMap nodeControlIdsMap
     * @return Map
     */
    Map<Long, List<Long>> nodesVisibleControlPermissionMap(Collection<Long> nodeIds, Map<Long, Set<Long>> nodeControlIdsMap);

    /**
     * 补充控件 权限
     *
     * @param controlPermissions controlPermissions
     * @param sourceControlIds   sourceControlIds
     * @return List
     */
    List<ControlPermissionDTO> supplyControlPermissions(List<ControlPermission> controlPermissions, Collection<Long> sourceControlIds);
}
